import Vue from 'vue'
import Router from 'vue-router'         // 路由模块

// 各组件引入
import Home from './views/Home.vue' 
import Playing from './views/Playing.vue'
import Comming from './views/Comming.vue'

// Vue.use() 添加模块，增加功能
Vue.use(Router)

// 单页应用 single page app（SPA)

export default new Router({
  /* mode 和 base 这两项默认的最好去掉 */
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes: [                   // 路由配置（以往的页面）
    {
      path:'/',
      redirect:'/home'   // 重定向
    },
    {
      path: '/home',              // 只有 / 代表默认路径           -- 必选
      name: 'home',           // 命名路由
      component: Home,         // 访问到路由时渲染的组件（页面） -- 必选
      children:[
        {path:'playing',component:Playing},
        {path:'comming',component:Comming},
        {path:'',redirect:'playing'}
      ]
    },
    {
      path: '/about',
      name: 'about',
      // 路由被访问时才进行加载（路由懒加载）打包时会分离对应的文件
      component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    },
    {
      // 动态路由
      path: '/mine/:userId',
      name:'mine',
      // component: 'Mine',
      component: ()=> import('./views/Mine.vue'),
    },
    {
      path:'/movie/:movieId',
      name:'movie',
      component:()=>import('./views/Movie.vue')
    },
    {
      path:'/shows/:cinemaId',
      name:'shows',
      component:()=>import('./views/Shows.vue')
    }
  ]
})
